/*
 * @Author: liaoxing
 * @Date: 2021-08-20 16:31:28
 * @LastEditors: liaoxing
 * @LastEditTime: 2021-08-24 14:52:27
 * @Description: file content
 * @FilePath: \数据中心\src\api\financeApi.js
 */
import axios from 'axios'
import cookies from '@/utils/cookies'

const serve = axios.create({
  baseURL: 'http://192.168.8.140:8001',
  timeout: 6000,
  headers:{
    "Content-Type": "application/json"
  }
})

serve.interceptors.request.use(
  config => {
      let token = cookies.getCookie('token')
      if (token) {
        config.headers.Authorization = token
      }
      if (config.method === "get") {
        config.data = { unused: 0 }
      }
      console.log(config)
      return config
  },
  error => {
      Promise.reject(error)
  }
)

serve.interceptors.response.use(
  response => {
      const res = response.data
      return res
  },
  error => {
      return Promise.reject(error)
  }
)

export default serve